<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Star(uname, age, song) {
        this.uname = uname
        this.age = age
        this.song = song
      }

      //将公共方法挂载到原型对象上
      Star.prototype.sing = function () {
        console.log(`我会唱${this.song}`)
      }

      const zjl = new Star('周杰伦', 40, '一路向北')

      //   console.log(Star.prototype)
      // 对象的隐式属性__proto__
      // 任意对象都有这个属性

      console.log(zjl)
      //   console.log(zjl.__proto__.constructor === Star)
      //   console.log(zjl.__proto__.__proto__ === Object.prototype)
      //   console.log(zjl.__proto__ === Star.prototype)

      //   console.log(zjl.__proto__.__proto__.constructor === Object)

      //   console.log(zjl.__proto__.__proto__.__proto__)

      //   zjl.dance()

      //new的过程
      //1.创建新对象
      //   const obj = {}

      // const obj = new Object()

      //   console.log(obj.__proto__ === Object.prototype)

      //2.改原型指向
      //   obj.__proto__ = Star.prototype
    </script>
  </body>
</html>
